import random
from fake_useragent import UserAgent
#第一步批量生成headers
# for i in range(20):
#     print(UserAgent().random)
#第二步 建立随机headers
user_agent_list = []
for i in range(20):
    user_agent_list.append(UserAgent().random)
headers = {"user-agent": random.choice(user_agent_list)}

# 上面的就可以直接运行,也可以下面的判断1
# if headers == None:
#     headers = {"user-agent": random.choice(user_agent_list)}
# else:
#     headers['user-agent'] = random.choice(user_agent_list)
print(headers)

